<template>
	<view class="card expenses" v-if="expenses?.length">
		<view class="card-title">费用说明</view>
		<view class="expenses-item" v-for="(item, index) in expenses" :key="index">
			<view class="table-header">{{ item.type_name }}</view>
			<view class="table-tr" v-for="(_item, _index) in item.sub_type_groups" :key="_index">
				<view class="first-table-td">{{ _item.sub_type_name }}</view>
				<view class="second-table-td">{{ _item.display_items.join("\n") }}</view>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
interface SubTypeGroups {
	sub_type_name: string
	display_items: string[]
}
interface Expenses {
	type_name: string
	sub_type_groups: SubTypeGroups[]
}

interface ExpensesProps {
	expenses: Expenses[]
}

defineProps<ExpensesProps>()
</script>

<style lang="scss" scoped>
@import "../../ticket/index.scss";

.expenses {
	padding-top: 34rpx;
	padding-bottom: 28rpx;

	.card-title {
		margin-bottom: 22rpx;
	}

	.expenses-item {
		overflow: hidden;
		border: 1rpx solid #e9eaee;
		border-radius: 16rpx;

		&:not(:last-child) {
			margin-bottom: 24rpx;
		}

		.table-header {
			padding: 22rpx 28rpx;
			background-color: #f8f8f9;
			text-align: center;
			font-size: 24rpx;
			color: #86909c;
			line-height: 34rpx;
		}

		.table-tr {
			display: flex;
			align-items: stretch;
			border-top: 1rpx solid #e9eaee;
		}

		.first-table-td {
			display: flex;
			align-items: center;
			width: 160rpx;
			padding: 30rpx 28rpx;
			text-align: center;

			&:not(:last-child) {
				border-right: 1rpx solid #e9eaee;
			}
		}

		.second-table-td {
			flex: 1;
			padding: 26rpx 24rpx 26rpx 40rpx;
			display: flex;
			align-items: center;
			white-space: break-spaces;
		}
	}
}
</style>
